namespace RuthlessConquest {
    public static class VersionsManager {
        public static Platform Platform { get; }

        public static BuildConfiguration BuildConfiguration => BuildConfiguration.Release;

        public static Version Version { get; }

        public static Version LastLaunchedVersion { get; set; }

        static VersionsManager() {
            //AssemblyName assemblyName = new AssemblyName(typeof(VersionsManager).GetTypeInfo().Assembly.FullName);
            //if ((uint)assemblyName.Version.Major > 255u || (uint)assemblyName.Version.Minor > 255u || (uint)assemblyName.Version.Build > 255u || (uint)assemblyName.Version.Revision > 255u)
            //{
            //throw new InvalidOperationException("Unsupported version number.");
            //}
            Platform = global::Game.VersionsManager.CurrentPlatform switch {
                global::Game.VersionsManager.Platform.Windows or global::Game.VersionsManager.Platform.Linux => Platform.Desktop,
                global::Game.VersionsManager.Platform.Android => Platform.Android,
                _ => Platform.Desktop
            };
            Version = new Version(1, 2, 1, 1);
        }

        public static void Initialize() {
            LastLaunchedVersion = SettingsManager.LastLaunchedVersion;
            SettingsManager.LastLaunchedVersion = Version;
            if (Version != LastLaunchedVersion) {
                AnalyticsManager.LogEvent(
                    "[VersionsManager] Upgrade game",
                    new AnalyticsParameter("LastVersion", LastLaunchedVersion.ToString()),
                    new AnalyticsParameter("CurrentVersion", Version.ToString())
                );
            }
        }
    }
}